using System;
using System.Linq.Expressions;

namespace devtm.Aop.InternalProcess
{
	public static class Confirm
	{
		#region Assertions

		public static void Assertion(Func<bool> predicate)
		{
			Assertion(predicate());
		}

		public static void Assertion(Func<bool> predicate, string message)
		{
			Assertion(predicate(), new InvalidOperationException(message));
		}

		public static void Assertion(Func<bool> predicate, Exception ex)
		{
			if (!predicate()) throw ex;
		}

		public static void Assertion(bool condition)
		{
			Assertion(condition, "Unable to assert statement. This usually happens when an invalid state is detected in the application.");
		}

		public static void Assertion(bool condition, string message)
		{
			Assertion(condition, new InvalidOperationException(message));
		}

		public static void Assertion(bool condition, Exception ex)
		{
			if (!condition) throw ex;
		}

		#endregion
	}
}
